<?php
/**
 * Created by PhpStorm.
 * User: HCDX
 * Date: 2018/5/24
 * Time: 14:05
 */
namespace app\admin\controller;
use think\Controller;
use app\admin\model\Admin;
class Login extends Controller
{
    public function index()
    {
        if(request()->isPost()){
            $admin = new Admin();
            //var_dump($admin);
            $num = $admin->login(input('post.'));
            //var_dump($num);die();
            //var_dump($num);die();
            if($num==1){
                $this->error('用户不存在');
            }
            if($num==2){
                $this->success('登录成功！',url('index/index'));
            }
            if($num==3){
                $this->error('密码错误');
            }
        }
        return view();
    }
    //验证码检测
    public function check($code=''){
        if(!captcha_check($code)){
            $this->error('验证码错误');
        }else{
            return true;
        }
    }
}